//
//  SettingTableViewCell.swift
//  CheckmeRing
//
//  Created by 董鹏 on 2022/2/16.
//

import UIKit

protocol SettingTableViewCellDelegate: NSObjectProtocol {
    func returnSwitchStateAndIndexPath(_ indexPath: IndexPath, state: Bool)
}

class SettingTableViewCell: UITableViewCell {

    weak var delegate:SettingTableViewCellDelegate?
    var indexPath: IndexPath!
    @IBOutlet weak var bgView: UIView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var stateSwitch: UISwitch!
    /// 右箭头
    @IBOutlet weak var rightDisclosure: UIImageView!
    /// 虚线
    @IBOutlet weak var separLine: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.stateSwitch.addTarget(self, action: #selector(switchDidChanged), for: UIControl.Event.valueChanged)
    }
    
    @objc func switchDidChanged() {
        if self.delegate != nil {
            self.delegate?.returnSwitchStateAndIndexPath(self.indexPath, state: self.stateSwitch.isOn)
        }
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
